﻿using System;
using System.Reflection;
using log4net;

namespace Mrb.Utils
{
    public class BatchProcessRunner
    {
        private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public static void Run(IBatchProcess batchProcess)
        {
            try
            {
                Logging.Initialize();
                var config = Configuration.CreateAndLoad();
                batchProcess.Open(config);
                batchProcess.Run();
            }
            catch (Exception e)
            {
                Log.Error(e);
                Console.WriteLine(e);
                throw;
            }
        }
    }
}